package com.skcc.ts.nsi.user;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.skcc.ts.nsi.R;
import com.skcc.ts.nsi.service.SocketClientService;

public class MEUsrRegiSearch extends Activity {
	EditText input_Id;
	EditText find_Id;
	EditText find_Name;
	private String addr;
	private String port;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.meusrregisearch);

		teamListing();

	}

	private void teamListing() {

		Intent receiveI = getIntent();
		boolean dolist = receiveI.getBooleanExtra("teamList", false);
		if (dolist) {
			String[] usr_id = receiveI.getStringArrayExtra("teamId");
			String[] usr_name = receiveI.getStringArrayExtra("teamName");
			String[] usr_role = receiveI.getStringArrayExtra("teamRole");
			addr = receiveI.getStringExtra("loginAddr");
			port = receiveI.getStringExtra("loginPort");

			TableLayout mtable = (TableLayout) findViewById(R.id.tableLayout_usr_regi_search_usrList);

			for (int i = 0; i < usr_id.length; i++) {
				TableRow tr = new TableRow(this);
				tr.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
				TextView text1 = new TextView(this);
				TextView text2 = new TextView(this);
				TextView text3 = new TextView(this);

				if (i % 2 == 1) {
					text1.setBackgroundColor(0xffd3daeb);
					text2.setBackgroundColor(0xffd3daeb);
					text3.setBackgroundColor(0xffd3daeb);
				} else {
					text1.setBackgroundColor(Color.WHITE);
					text2.setBackgroundColor(Color.WHITE);
					text3.setBackgroundColor(Color.WHITE);
				}

				text1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
				text1.setText(usr_id[i]);
				text1.setGravity(Gravity.CENTER);
				text1.setTextSize(20);
				text1.setTextColor(Color.BLACK);

				text2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
				text2.setText(usr_name[i]);
				text2.setGravity(Gravity.CENTER);
				text2.setTextSize(20);
				text2.setTextColor(Color.BLACK);

				text3.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
				text3.setText(usr_role[i]);
				text3.setGravity(Gravity.CENTER);
				text3.setTextSize(20);
				text3.setTextColor(Color.BLACK);

				tr.addView(text1, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1));
				tr.addView(text2, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 2));
				tr.addView(text3, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 3));

				mtable.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
			}

		} else {
			new AlertDialog.Builder(MEUsrRegiSearch.this).setTitle("Alert").setMessage("팀원 조회 권한이 없습니다.").setPositiveButton("OK", null)
					.show();
		}

	}

}